/**
 * 给定矩阵，循环移位
 * 规模不大，直接模拟
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;

int N, M, X, Y;
vector<string> Borad;
int P, Q;
int Sx, Sy;

vector<char> Rtmp, Ctmp;

void moveRow(int z){
    Rtmp.assign(M, {});
    copy(Borad[z].begin(), --Borad[z].end(), Rtmp.begin() + 1);
    Borad[z][0] = Borad[z][M - 1];
    copy(Rtmp.begin() + 1, Rtmp.end(), Borad[z].begin() + 1);
    return;
}

void moveCol(int z){
    Ctmp.assign(N, {});
    for(int i=0;i<N-1;++i) Ctmp[i] = Borad[i][z];
    Borad[0][z] = Borad[N - 1][z];
    for(int i=0;i<N-1;++i) Borad[i + 1][z] = Ctmp[i];
    return;
}

vector<pii> Cmds;

char proc(){
    --X, --Y;
    for(int p=1;p<=P;++p){
        for(auto [cmd, z] : Cmds){
            z -= 1;
            if(1 == cmd){
                moveRow(z);
                // for(auto & s : Borad) cout << s << endl;
                // cout << endl;
            }else{
                moveCol(z);
            }
        }        
    }
    return Borad[X][Y];    
}

void work(){
    cin >> N >> M >> X >> Y;
    Borad.assign(N, {});
    for(auto & s : Borad) cin >> s;
    cin >> P >> Q;
    Cmds.assign(Q, {});
    for(auto & p : Cmds) cin >> p.first >> p.second;
    cout << proc() << "\n";


    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) work();
    return 0;
}